package com.atmilan.quartz.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.atmilan.quartz.constant.Constants;
import com.atmilan.quartz.constant.enums.SyncStatusEnum;
import com.atmilan.quartz.model.dto.customs.HgCheckDTO;
import com.atmilan.quartz.model.dto.customs.HgCheckDTO.Body179DTO;
import com.atmilan.quartz.model.dto.customs.HgCheckDTO.GoodsInfoDTO;
import com.atmilan.quartz.model.dto.customs.HgCheckDTO.Head179DTO;
import com.atmilan.quartz.model.entity.crmeb.StoreOrder;
import com.atmilan.quartz.model.entity.crmeb.StoreOrderCustoms;
import com.atmilan.quartz.model.entity.crmeb.StoreOrderInfo;
import com.atmilan.quartz.model.request.JackyunGoodsRequest;
import com.atmilan.quartz.model.result.crmeb.StoreCartResponse;
import com.atmilan.quartz.service.IJkySyncApiService;
import com.atmilan.quartz.service.IStoreOrderCustomsService;
import com.atmilan.quartz.service.IStoreOrderInfoService;
import com.atmilan.quartz.service.IStoreOrderService;
import com.atmilan.quartz.utils.CommonResult;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.*;

/**
 * @author daigb
 * @date:  2021-11-19 13:44    
 *
 */
@Log4j2
@RestController
@RequestMapping("api/jky")
@Api(tags = "吉客云商品同步")
public class JkyGoodsController {

    @Autowired
	IJkySyncApiService jkySyncApiService;

	@ApiOperation(value = "吉客云单商品获取")
	@RequestMapping(value = "/syncJkyGoods", method = RequestMethod.POST)
	public CommonResult<Object> syncJkyGoods(@RequestBody JackyunGoodsRequest jackyunGoodsRequest) {

			boolean result = jkySyncApiService.syncProduct(jackyunGoodsRequest.getGoodsNo(),
					jackyunGoodsRequest.getStartDateModifiedSku(),jackyunGoodsRequest.getEndDateModifiedSku());
			if (result) {

				log.warn("--------------- 吉客云商品同步完成!!! ---------------");

				boolean result1 = jkySyncApiService.pushProduct();
				if (result1) {

					log.warn("--------------- 吉客云商品下发完成!!! ---------------");
				}
			}

		return CommonResult.success();
	}
	
}

